package com.shadowtorcher.TableRolePlayingSystem.DataStructure;

import java.util.ArrayList;

public class SegmentItem {
    static final int STRING = 0;
    static final int SEGMENT = 1;
    static final int ARRAY = 3;
    String string;
    DataSegment dataSegment;
    ArrayList<String> array;
    int type;

    SegmentItem(String string) {
        type = STRING;
        this.string = string;
    }

    SegmentItem(DataSegment dataSegment) {
        type = SEGMENT;
        this.dataSegment = dataSegment;
    }

    SegmentItem(ArrayList<String> array) {
        type = ARRAY;
        this.array = array;
    }

    public String getString() {
        return string;
    }

    public DataSegment getDataSegment() {
        return dataSegment;
    }

    public void setDataSegment(DataSegment dataSegment) {
        this.dataSegment = dataSegment;
    }

    @Override
    public String toString() {
        if (this.type == STRING)
            return string;
        else if (this.type == SEGMENT)
            return DataProcessor.buildString(dataSegment);
        else if (this.type == ARRAY)
            return array.toString();
        return "null";
    }

    public boolean isString() {
        return this.type == STRING;
    }

    public void setString(String string) {
        this.string = string;
    }

    public boolean isSegment() {
        return this.type == SEGMENT;
    }

    public boolean isArray() {
        return this.type == ARRAY;
    }

    public ArrayList<String> getArray() {
        return array;
    }

    public void setArray(ArrayList<String> array) {
        this.array = array;
    }
}
